<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<style>
    body {
        padding: 50px;
    }
    
    .mydiv {
        height: 200px;
        width: 200px;
        border: 1px solid #ccc;
        margin-bottom: 20px;
        display: inline-block;
    }
    
    .case1 {
        padding: .5em;
        line-height: 1.5;
        background: beige;
        background-image: linear-gradient( rgba(0, 0, 0, .2) 50%, transparent 0);
        background-size: auto 3em;
    }
    /* 有一个办法可以解决这个问题，那就是用background-position 把向
条纹向底部移动.5em。不过，如果我们以后决定调整内边距，还需要相应
地修改背景定位值，这显然不够DRY。可以让背景自动跟着内边距的宽度
走吗？ */
    
    .case2 {
        padding: .5em;
        line-height: 1.5;
        background: beige;
        background-image: linear-gradient( rgba(0, 0, 0, .2) 50%, transparent 0);
        background-size: auto 3em;
        background-origin: content-box;
    }
    /* 唯一可能破坏效果的
情况②可能就是在改变line-height 时忘了相应地调整background-size。 */
    
    pre {
        padding: .5em;
        line-height: 1.5;
        background: hsl(20, 50%, 95%);
        font-family: Consolas, Monaco, monospace;
    }
    
    pre:nth-of-type(2) {
        tab-size: 2
    }
    
    pre:nth-of-type(3) {
        tab-size: 4
    }
    
    pre:nth-of-type(4) {
        tab-size: 0
    }
    
    code {
        font: inherit;
    }
</style>

<body>
    <div class="mydiv case1">
        <div>1111</div>
        <div>1111</div>
        <div>1111</div>
        <div>1111</div>
    </div>
    <div class="mydiv case2">
        <div>1111</div>
        <div>1111</div>
        <div>1111</div>
        <div>1111</div>
    </div>
    <pre>
      <code>
// tab-size: 2;
while (true) {
  var d = new Date();
  if (d.getDate()==1 &amp;&amp;
      d.getMonth()==3) {
    alert("TROLOLOL");
  }
}
      </code>
    </pre>
</body>

</html>